
package uk.org.cardboardbox.problemmachine;

import android.app.Application;
import android.os.Environment;

import java.io.File;

public class ProblemMachineApplication extends Application {

    private File dataDir;

    private final String[] samples = new String[] {
        "simpleshift.json"
    };

    @Override
    public void onCreate() {
        super.onCreate();
        dataDir = new File(Environment.getExternalStorageDirectory(), "problemmachine");
        if (!dataDir.exists()) {
            dataDir.mkdirs();
        }
        installSamples();

    }

    protected File getDataDir() {
        return dataDir;
    }

    private void installSamples() {
        File sampleDir = new File(dataDir, "samples");
        if (!sampleDir.exists())
            sampleDir.mkdirs();
        for (String s : samples)
            AssetUtils.extractAsset(getApplicationContext(), s, new File(sampleDir, s));
    }

}
